;(function(){
  'use strict';
  angular.module('controllers.faultLocation.tradeLog',[])
  .controller('TradeLogCtrl', tradeLogCtrl);
  /**
   * 交易日志统计控制器,初始化一些子控制器公用参数
   * @param  {Object}  $scope  
   */
  function tradeLogCtrl($scope,CoreService,IndexIsAnormal,$state,$mdDialog){
    var tabs = ['/query','/management'];
    var confirm = $mdDialog.confirm().title('提示').content('交易日志指标异常，是否进入管理页面').ok('是').cancel('否');
    $scope.toggle = true;
    $scope.isQuery = false;
    $scope.isResponded = true;
    
    if(IndexIsAnormal && $scope.selectedIndex === 0){
      $mdDialog.show(confirm).then(function() {
        $state.go('sas.faultLocation.tradeLog.management');
        $scope.selectedIndex = CoreService.navgit(tabs);
      });
    }
    $scope.selectedIndex = CoreService.navgit(tabs);
    $scope.$on('$stateChangeSuccess', function(evt, state) {
      $scope.selectedIndex = tabs.indexOf(state.url);
    });
  }

  tradeLogCtrl.$inject = ['$scope','CoreService','IndexIsAnormal','$state','$mdDialog'];
})();